package cn.zn.modules.budget.cur.controller;

import cn.zn.framework.common.utils.PageInUtils;
import cn.zn.framework.common.utils.PageUtils;
import cn.zn.framework.common.utils.R;
import cn.zn.modules.budget.cur.entity.TBudgetInDetailEntity;
import cn.zn.modules.budget.cur.service.TBudgetInDetailService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;


/**
 * 预算分配明细
 *
 * @author zn
 * @email zhunahao@qq.com
 * @date 2019-12-10 14:27:52
 */
@RestController
@RequestMapping("budget/tbudgetindetail")
public class TBudgetInDetailController {

    @Autowired
    private TBudgetInDetailService tBudgetInDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("budget:tbudgetindetail:list")
    public R list(PageInUtils<TBudgetInDetailEntity> pageIn) {

        TBudgetInDetailEntity tBudgetInDetail = new TBudgetInDetailEntity();
        PageUtils pageUtils = tBudgetInDetailService.queryPage(tBudgetInDetail, pageIn.getPageObj());

        return R.ok().put("page", pageUtils);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("budget:tbudgetindetail:info")
    public R info(@PathVariable("id") String id) {
            TBudgetInDetailEntity tBudgetInDetail = tBudgetInDetailService.getById(id);

        return R.ok().put("tBudgetInDetail", tBudgetInDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("budget:tbudgetindetail:save")
    public R save(@RequestBody TBudgetInDetailEntity tBudgetInDetail) {
            tBudgetInDetailService.save(tBudgetInDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("budget:tbudgetindetail:update")
    public R update(@RequestBody TBudgetInDetailEntity tBudgetInDetail) {
            tBudgetInDetailService.updateById(tBudgetInDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("budget:tbudgetindetail:delete")
    public R delete(@RequestBody String[] ids) {
            tBudgetInDetailService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
